<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/prop-types.js"></script>
    <script src="../js/babel.min.js"></script>
  </head>
  <body>
    <div id="test1"></div>
    <div id="test2"></div>

    <script type="text/babel">
      class UserInfo extends React.Component {
        render() {
          return (
            <ul>
              <li>姓名是：{this.props.name}</li>
              <li>性别是：{this.props.sex}</li>
              <li>年龄是：{this.props.age}</li>
              <li>兴趣是：{this.props.hobby}</li>
            </ul>
          );
        }

        static propTypes = {
          name: PropTypes.string.isRequired,
          age: PropTypes.number.isRequired,
          sex: PropTypes.string.isRequired,
          hobby: PropTypes.string.isRequired,
        };

        static defaultProps = {
          name: "松岛枫",
        };
      }

      let msg = {
        sex: "男",
        age: 18,
      };

      ReactDOM.render(
        <UserInfo {...msg} hobby="篮球" />,
        document.getElementById("test1")
      );
      ReactDOM.render(
        <UserInfo {...msg} hobby="足球" />,
        document.getElementById("test2")
      );
    </script>
  </body>
</html>
